package com.leonzhangxf.spel.reference;

import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

/**
 * Literal Expressions.
 *
 * @author leonzhangxf
 * @date 20190427
 */
public class LiteralExpressions {

    public static void main(String[] args) {
        ExpressionParser parser = new SpelExpressionParser();

        // evals to "Hello World"
        String helloWorld = (String) parser.parseExpression("'Hello World'").getValue();
        System.out.println(helloWorld);

        System.out.println(parser.parseExpression("6.0221415E+23").getValue(Double.class));

        // evals to 2147483647
        System.out.println(parser.parseExpression("0x7FFFFFFF").getValue(Integer.class));

        System.out.println(parser.parseExpression("true").getValue(Boolean.class));

        Object nullValue = parser.parseExpression("null").getValue();
        System.out.println(nullValue);
        System.out.println(nullValue == null);
    }
}
